~ chicken-core (chicken-5) /manual/Module (chicken io)
Trap1[[tags: manual]]
2[[toc:]]
3
4== Module (chicken io)
5
6This module provides various Input/Output extensions.
7
8=== read-list
9
10<procedure>(read-list [PORT [READER [MAX]]])</procedure>
11
12Call {{READER}} up to {{MAX}} times and collect its output in a list. If {{MAX}} is {{#f}}, read until end of file.
13
14The reader is called with one argument: {{PORT}}.
15
16{{READER}} defaults to {{read}}, {{MAX}} to {{#f}} and {{PORT}} to {{current-input-port}}, so if you call it with no arguments, it will read all remaining s-expressions from the current input port.
17
18
19=== read-buffered
20
21<procedure>(read-buffered [PORT])</procedure>
22
23Reads any remaining data buffered after previous read operations on
24{{PORT}}. If no remaining data is currently buffered, an empty string
25is returned. This procedure will never block. Currently only useful
26for string-, process- and tcp ports.
27
28=== read-byte
29=== write-byte
30
31<procedure>(read-byte [PORT])</procedure><br>
32<procedure>(write-byte BYTE [PORT])</procedure>
33
34Read/write a byte to the port given in {{PORT}}, which default to the values
35of {{(current-input-port)}} and {{(current-output-port)}}, respectively.
36
37
38=== read-line
39=== write-line
40
41<procedure>(read-line [PORT [LIMIT]])</procedure><br>
42<procedure>(write-line STRING [PORT])</procedure>
43
44Line-input and -output. {{PORT}} defaults to the value of
45{{(current-input-port)}} and {{(current-output-port)}},
46respectively. If the optional argument {{LIMIT}} is given and
47not {{#f}}, then {{read-line}} reads at most {{LIMIT}}
48characters per line. {{read-line}} returns a string without the terminating newline and {{write-line}} adds a terminating newline before outputting.
49
50
51=== read-lines
52
53<procedure>(read-lines [PORT [MAX]])</procedure>
54
55Read {{MAX}} or fewer lines from {{PORT}}. {{MAX}} defaults to
56{{most-positive-fixnum}} and {{PORT}} defaults to the value of
57{{(current-input-port)}}. Returns a list of strings, each string
58representing a line read, not including any line separation
59character(s).
60
61
62=== read-string
63=== read-string!
64=== write-string
65
66<procedure>(read-string [NUM [PORT]])</procedure><br>
67<procedure>(read-string! NUM STRING [PORT [START]])</procedure><br>
68<procedure>(write-string STRING [NUM [PORT]])</procedure>
69
70Read or write {{NUM}} characters from/to {{PORT}}, which defaults to the
71value of {{(current-input-port)}} or {{(current-output-port)}}, respectively.
72
73If {{NUM}} is {{#f}} or not given, then all data up to the end-of-file is
74read, or, in the case of {{write-string}} the whole string is written. If no
75more input is available, {{read-string}} returns {{#!eof}}.
76
77{{read-string!}} reads destructively into the given {{STRING}} argument, but
78never more characters than would fit into {{STRING}}. If {{START}} is given,
79then the read characters are stored starting at that position.
80{{read-string!}} returns the actual number of characters read.
81
82
83=== read-token
84
85<procedure>(read-token PREDICATE [PORT])</procedure>
86
87Reads characters from {{PORT}} (which defaults to the value of {{(current-input-port)}})
88and calls the procedure {{PREDICATE}} with each character until {{PREDICATE}} returns
89false. Returns a string with the accumulated characters.
90
91---
92Previous: [[Module (chicken gc)]]
93
94Next: [[Module (chicken irregex)]]